//package com.dc.dbus.netty.exception;
//
//import java.io.IOException;
//import java.util.Arrays;
//import java.util.List;
//import java.util.concurrent.TimeUnit;
//
//import com.dc.dbus.netty.ITestService;
//import com.dc.dbus.session.client.Client;
//import com.dc.dbus.session.listener.ClientSideEventListener;
//import com.dc.dbus.session.listener.ServerSideEventListener;
//import com.dc.dbus.session.server.Server;
//import com.dc.dbus.transport.commons.ClientSideTransport;
//import com.dc.dbus.transport.commons.ServerSideTransport;
//import com.dc.dbus.transport.netty.client.NettyClientSideTransport;
//import com.dc.dbus.transport.netty.register.ServiceRegister;
//import com.dc.dbus.transport.netty.register.ZookeeperServiceRegister;
//import com.dc.dbus.transport.netty.server.NettyServerSideTransport;
//
//public class ServiceDisconnectTest_Client {
//
//	protected final static ClientSideEventListener clientSideEventListener = new ClientSideEventListener() {
//		@Override
//		public void exception(String message, Exception e) {
//			System.err.println(message);
//			e.printStackTrace(System.err);
//		}
//	};
//	
//	protected final static ServerSideEventListener serverSideEventListener = new ServerSideEventListener() {
//		@Override
//		public void queueFull(String message, Exception e) {
//			System.err.println(message);
//			e.printStackTrace(System.err);
//		}
//
//		@Override
//		public void methodExcuteException(String message, Throwable t) {
//			System.err.println(message);
//			t.printStackTrace(System.err);
//		}
//
//		@Override
//		public void dbusException(String message, Exception e) {
//			System.err.println(message);
//			e.printStackTrace(System.err);
//		}
//	};
//	
//	public static Client getClient(String serviceName) throws IOException {
//		
//		List<String> serviceNames = Arrays.asList(new String[] {serviceName});
//		ServiceRegister serviceRegister = new ZookeeperServiceRegister("127.0.0.1:2181");
//		ClientSideTransport clientSideTansport = new NettyClientSideTransport(serviceNames, serviceRegister, 4);
//		Client client = new Client(serviceName, clientSideTansport, clientSideEventListener);
//		
//		return client;
//	}
//	
//	public static Server initServer(String serviceName, String[] serviceRegion, int servicePort, int sessionTimeout) throws IOException {
//		
//		ServiceRegister serviceRegister = new ZookeeperServiceRegister("127.0.0.1:2181", sessionTimeout);
//		
//		ServerSideTransport serverSideTansport = new NettyServerSideTransport(serviceName, serviceRegion, 
//				servicePort, serviceRegister);
//		
//		Server server = new Server(serverSideTansport, null, serverSideEventListener);
//		
//		return server;
//	}
//	
//	public static void main(String[] args) throws Exception {
//		
//		System.out.println("启动客户端");
//		
//		Client client = getClient("ServerName-Demo");
//		
//		ITestService clientStub = client.createClientStub(ITestService.class);
//		
//		TimeUnit.MILLISECONDS.sleep(5000);
//		
//		System.out.println("客户端调用1");
//		
//		// TODO 调用过程为10秒，中途需手动断开服务端或客户端
//		try {
//			clientStub.test1("ts0", "111");
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		
//	}
//}
